package interceptor

import okhttp3.Interceptor
import okhttp3.Response

/**
 * Authorization拦截器，自动注入Authorization字段
 * @author BX-Gin
 * @since 2024/6/6 上午11:51
 */
class AuthorizationInterceptor(private val authorization: String) : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val request = chain.request().newBuilder()
            .addHeader(HEADER, authorization)
            .build()
        return chain.proceed(request)
    }

    companion object {
        const val HEADER = "Authorization"
    }
}